/**
 * 
 */
package core;

import java.net.Proxy;
import java.net.ProxySelector;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import javax.net.SocketFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSocketFactory;

import okhttp3.Authenticator;
import okhttp3.Cache;
import okhttp3.CertificatePinner;
import okhttp3.ConnectionPool;
import okhttp3.ConnectionSpec;
import okhttp3.CookieJar;
import okhttp3.Dns;
import okhttp3.OkHttpClient;
import okhttp3.OkHttpClient.Builder;
import okhttp3.Protocol;

/**
 * @author Crystalline
 * @GiteePage https://gitee.com/crystallineDW/krn
 * @writein 2022/3/17
 */
public class KRNmanager {

	private OkHttpClient Client;
	
	private Builder builder;

	// Header_List
	Map<String, String> Header;

	public KRNmanager() {
		Client = new OkHttpClient();
		builder = Client.newBuilder();
	}

	// AddHeader
	public void addHeader(String key, String value) {
		Header = new HashMap<>();
		Header.put(key + "", value + "");
	}

	// Other Function
	public void connectTimeout(long timeout, TimeUnit unit) {
		builder.connectTimeout(timeout, unit);
	}

	public void readTimeout(long timeout, TimeUnit unit) {
		builder.readTimeout(timeout, unit);
	}

	public void writeTimeout(long timeout, TimeUnit unit) {
		builder.writeTimeout(timeout, unit);
	}

	public void proxy(Proxy proxy) {
		builder.proxy(proxy);

	}

	public void proxySelector(ProxySelector proxySelector) {
		builder.proxySelector(proxySelector);

	}

	public void cookieJar(CookieJar cookieJar) {
		builder.cookieJar(cookieJar);

	}

	public void cache(Cache cache) {
		builder.cache(cache);

	}

	public void dns(Dns dns) {
		builder.dns(dns);

	}

	public void socketFactory(SocketFactory socketFactory) {
		builder.socketFactory(socketFactory);

	}

	public void sslSocketFactory(SSLSocketFactory sslSocketFactory) {
		builder.sslSocketFactory(sslSocketFactory);

	}

	public void hostnameVerifier(HostnameVerifier hostnameVerifier) {
		builder.hostnameVerifier(hostnameVerifier);

	}

	public void certificatePinner(CertificatePinner certificatePinner) {
		builder.certificatePinner(certificatePinner);

	}

	public void authenticator(Authenticator authenticator) {
		builder.authenticator(authenticator);

	}

	public void proxyAuthenticator(Authenticator proxyAuthenticator) {
		builder.proxyAuthenticator(proxyAuthenticator);

	}

	public void connectionPool(ConnectionPool connectionPool) {
		builder.connectionPool(connectionPool);

	}

	public void followSslRedirects(boolean followProtocolRedirects) {
		builder.followSslRedirects(followProtocolRedirects);

	}

	public void followRedirects(boolean followRedirects) {
		builder.followRedirects(followRedirects);

	}

	public void retryOnConnectionFailure(boolean retryOnConnectionFailure) {
		builder.retryOnConnectionFailure(retryOnConnectionFailure);

	}

	public void protocols(List<Protocol> protocols) {
		builder.protocols(protocols);

	}

	public void connectionSpecs(List<ConnectionSpec> connectionSpecs) {
		builder.connectionSpecs(connectionSpecs);
	}

	public OkHttpClient getClient() {
		return this.Client;
	}

	public Builder getBuilder() {
		return this.builder;
	}

	public void setClient(OkHttpClient client) {
		this.Client = client;
	}

	public void setBuilder(Builder builder) {
		this.builder = builder;
	}


}
